import numpy as np
from simple_tif import array_to_tif

x = np.linspace(0, 1, 100)
y = np.linspace(0, 1, 100)
z = np.linspace(0, 1, 100)

x = x.reshape(1, 1, x.size)
y = y.reshape(1, y.size, 1)
z = z.reshape(z.size, 1, 1)

def spherical_shell(outer_radius, inner_radius, center):
    print outer_radius, inner_radius, center
    r = np.sqrt((center[0] - z)**2 +
                (center[1] - y)**2 +
                (center[2] - x)**2)
    return (np.ones(r.shape, dtype=np.float64) *
            (r < outer_radius) *
            (r > inner_radius))

thickness = 0.01
first_radius = 0.4
delta_r = 0.05
num = 8
shells = np.zeros_like(x+y+z)
print shells.shape
for i in range(num):
    shells += spherical_shell(
        outer_radius=first_radius - i*delta_r,
        inner_radius=first_radius - i*delta_r - thickness,
        center=(0.5*z.max(),
                0.5*y.max() + i*(delta_r-thickness),
                0.5*x.max()))

array_to_tif(shells.astype(np.float32), 'test.tif')
